package com.apes.framework.plugin.esb.parser.element;


import com.apes.framework.plugin.esb.processor.ChainProcessor;
import com.apes.framework.plugin.filereader.xml.ApesElement;

/**
 * 功能：抽象嵌套处理器元素解析器
 *
 * @author xul
 * @create 2018-04-21 10:46
 */
public abstract class AbstractNestedProcessorParser extends AbstractProcessorParser {

    @Override
    public ChainProcessor parse(ApesElement element) {
        ChainProcessor processor = super.parse(element);
        parseNestedElements(element, processor);
        return processor;
    }

    protected void parseNestedElements(ApesElement element, ChainProcessor processor){
        element.getNestedElements().stream().forEach(nestedElement -> {
            processor.setProcessor(nestedElement.parse());
        });
    }
}
